import { defineStore } from "pinia";

interface TaskState{
    taskList:string[]
}

export const useTaskStore = defineStore("taskStore",{
    state:():TaskState=>({
        taskList: [] as string[]
    }),
    getters: {
        hasTask:(state)=>state.taskList.length>0
    },
    actions: {
        addTask(task:string){
            this.taskList.push(task);
        },  
        clearTask(){
            this.taskList.length = 0;
        },
        delTask(task:string){
            this.taskList = this.taskList.filter((item)=>item!=task);
        }
    }
});